package com.ruoyi.project.system.newfunction.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.newfunction.domain.Exam_cost;
import com.ruoyi.project.system.newfunction.service.Exam_costService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/system/exam_cost")
@RestController
public class Exam_costController extends BaseController {
    @Autowired
    private Exam_costService exam_costService;

    /**
     * 基于查询条件进行分页查询检查项目
     * @param exam_cost 查询条件
     * @return
     */
    @RequestMapping("/list")
    @PreAuthorize("@ss.hasPermi('system:exam_cost:list')")
    public TableDataInfo findAllExamCostByPage(Exam_cost exam_cost){
        startPage();
        List<Exam_cost> allExamCostByPage = exam_costService.findAllExamCostByPage(exam_cost);
        return getDataTable(allExamCostByPage);
    }

    /**
     * 添加检查项目
     * @param exam_cost 检查项目对象
     * @return
     */
    @RequestMapping("/add")
    @PreAuthorize("@ss.hasAnyPermi('system:exam_cost:add')")
    public AjaxResult addExamCost(@RequestBody Exam_cost exam_cost){
        int i = exam_costService.addExamCost(exam_cost);
        return toAjax(i);
    }

    /**
     *  根据条件查询指定检查项目信息
     * @param examId  执行检查项目信息的编号
     * @return
     */
    @GetMapping("/{examId}")
    @PreAuthorize("@ss.hasPermi('system:exam_cost:list')")
    public AjaxResult findAllExamCostByPage(@PathVariable Integer examId){
        Exam_cost examCost = exam_costService.getExamCost(examId);
        return AjaxResult.success(examCost);
    }

    /**
     * 修改指定编号检查项目信息
     * @param exam_cost 指定修改检查项目的信息
     * @return
     */
    @PutMapping("/update")
    @PreAuthorize("@ss.hasAnyPermi('system:exam_cost:edit')")
    public AjaxResult updateExamCost(@RequestBody Exam_cost exam_cost){
        int i = exam_costService.updateExamCost(exam_cost);
        return toAjax(i);
    }

    @DeleteMapping("/{examIds}")
    @PreAuthorize("@ss.hasAnyPermi('system:exam_cost:remove')")
    public AjaxResult removeExamCost(@PathVariable Long [] examIds){
        int i = exam_costService.removeExamCost(examIds);
        return toAjax(i);
    }


}
